package com.example.demo.common.response;






import java.io.Serializable;
import java.util.List;

public class BaseServiceResponse<T> extends ServiceResponse implements Serializable {

	private static final long serialVersionUID = 1L;

	T response = null;
	public BaseServiceResponse(){
	}

	public BaseServiceResponse(Integer code, String desc){
		this.setCode(code);
		this.setDesc(desc);
		this.setResponse_time(DateUtil.longfmtNow());
	}
	public BaseServiceResponse(T resp,Integer code, String desc){
		this.setResponse(resp);
		this.setCode(code);
		this.setDesc(desc);
		this.setResponse_time(DateUtil.longfmtNow());
	}
	public BaseServiceResponse(ServiceError error, Integer code, String desc){
		this.addError(error);
		this.setCode(code);
		this.setDesc(desc);
		this.setResponse_time(DateUtil.longfmtNow());
	}
	public BaseServiceResponse(List<ServiceError> error, Integer code, String desc){
		this.setErrors(error);
		this.setCode(code);
		this.setDesc(desc);
		this.setResponse_time(DateUtil.longfmtNow());
	}

	public BaseServiceResponse(T resp, Integer code, String desc,Long total){
		this.setResponse(resp);
		this.setCode(code);
		this.setDesc(desc);
		this.setTotal(total);
		this.setResponse_time(DateUtil.longfmtNow());
	}
	public T getResponse() {
		return response;
	}

	public void setResponse(T response) {
		this.response = response;
	}

	@Override
	public String toString() {
		return JsonMapper.toJsonString(this);
	}
}
